﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace Bocom.ICenter.UI.Silverlight.Models
{
    using System.Linq;
    /// <summary>
    /// 地图监控 实体类
    /// </summary>
    public class RouteTreeViewEntity
    {
        /// <summary>
        ///  生成 线路车辆状态树 _ del
        /// </summary>
        /// <param name="BindRouteItem"></param>
        /// <param name="BindBusItem"></param>
        /// <returns></returns>
        public List<ForumInfo> GetForumData(List<ClassRouteEntity> BindRouteItem, List<ClassBusEntity> BindBusItem)
        {
            List<ForumInfo> forumList = new List<ForumInfo>();
            ///节点标识
            int NodeID = 1;
            //当前父节点ID
            int ChildParientID = 0;
            List<ClassBusEntity> RouteBusItem = new List<ClassBusEntity>();


            for (int i = 0; i < BindRouteItem.Count; i++)
            {
                forumList.Add(new ForumInfo() { ForumID = NodeID, ParendID = 0, ForumName = BindRouteItem[i].RouteName, UbiRouteId = BindRouteItem[i].ubiRouteId.ToString() });
                ChildParientID = NodeID;
                NodeID += 1;
                var db = from p in BindBusItem
                         select
                             new ClassBusEntity
                             {
                                 RouteID = p.RouteID,
                             };

                RouteBusItem = db.ToList();


                //添加 车辆的子节点
                for (int j = 0; j < RouteBusItem.Count; j++)
                {
                    forumList.Add(new ForumInfo() { ForumID = NodeID, ParendID = ChildParientID, ForumName = BindBusItem[j].InsideCode, UbiRouteId = BindBusItem[j].ubiRouteId.ToString() });
                    NodeID += 1;
                }
            }










            //forumList.Add(new ForumInfo() { ForumID = 1, ParendID = 0, ForumName = "0451线路", RouteID = "0451" });
            //forumList.Add(new ForumInfo() { ForumID = 2, ParendID = 0, ForumName = "0581线路", RouteID = "0581" });

            //forumList.Add(new ForumInfo() { ForumID = 3, ParendID = 1, ForumName = "02S0D041", RouteID = "0451" });
            //forumList.Add(new ForumInfo() { ForumID = 4, ParendID = 1, ForumName = "02S0D042", RouteID = "0451" });
            //forumList.Add(new ForumInfo() { ForumID = 5, ParendID = 1, ForumName = "02S0D043", RouteID = "0451" });
            //forumList.Add(new ForumInfo() { ForumID = 6, ParendID = 1, ForumName = "02S0D044", RouteID = "0451" });

            //forumList.Add(new ForumInfo() { ForumID = 7, ParendID = 2, ForumName = "06S0D065", RouteID = "0988" });
            //forumList.Add(new ForumInfo() { ForumID = 8, ParendID = 2, ForumName = "06S0D066", RouteID = "0988" });
            //forumList.Add(new ForumInfo() { ForumID = 9, ParendID = 2, ForumName = "06S0D067", RouteID = "0988" });






            return forumList;
        }



        /// <summary>
        /// 生成 线路车辆状态树
        /// </summary>
        /// <param name="routeInfo">线路信息集合</param>     
        /// <returns></returns>
        public List<ForumInfo> GetForumData(List<ClassRouteEntity> routeInfo)
        {
            List<ForumInfo> forumList = new List<ForumInfo>();
            ///节点标识
            int NodeID = 1;
            //当前父节点ID
            int ChildParientID = 0;


            for (int i = 0; i < routeInfo.Count; i++)
            {
                forumList.Add(new ForumInfo() { ForumID = NodeID, ParendID = 0, ForumName = routeInfo[i].RouteName, UbiRouteId = routeInfo[i].ubiRouteId.ToString() });
                ChildParientID = NodeID;
                NodeID += 1;


                //添加 车辆的子节点
                for (int j = 0; j < routeInfo[i].BusInfoList.Count; j++)
                {
                    forumList.Add(new ForumInfo() { ForumID = NodeID, ParendID = ChildParientID, ForumName = routeInfo[i].BusInfoList[j].InsideCode, UbiRouteId = routeInfo[i].BusInfoList[j].ubiRouteId.ToString() });
                    NodeID += 1;
                }
            }


            return forumList;
        }


    }
    /// <summary>
    /// 
    /// </summary>
    public class ForumInfo
    {
        /// <summary>
        /// 节点ID
        /// </summary>
        public int ForumID { get; set; }
        /// <summary>
        /// 父节点
        /// </summary>
        public int ParendID { get; set; }
        /// <summary>
        /// 节点名称
        /// </summary>
        public string ForumName { get; set; }
        /// <summary>
        /// 线路流水号
        /// </summary>
        public string UbiRouteId { get; set; }
    }


    /// <summary>
    /// 
    /// </summary>
    public class DataService
    {

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public List<ForumInfo> GetForumData()
        {
            List<ForumInfo> forumList = new List<ForumInfo>();
            forumList.Add(new ForumInfo() { ForumID = 1, ParendID = 0, ForumName = "0451线路", UbiRouteId = "0451" });
            forumList.Add(new ForumInfo() { ForumID = 2, ParendID = 0, ForumName = "0581线路", UbiRouteId = "0581" });

            forumList.Add(new ForumInfo() { ForumID = 3, ParendID = 1, ForumName = "02S0D041", UbiRouteId = "0451" });
            forumList.Add(new ForumInfo() { ForumID = 4, ParendID = 1, ForumName = "02S0D042", UbiRouteId = "0451" });
            forumList.Add(new ForumInfo() { ForumID = 5, ParendID = 1, ForumName = "02S0D043", UbiRouteId = "0451" });
            forumList.Add(new ForumInfo() { ForumID = 6, ParendID = 1, ForumName = "02S0D044", UbiRouteId = "0451" });

            forumList.Add(new ForumInfo() { ForumID = 7, ParendID = 2, ForumName = "06S0D065", UbiRouteId = "0988" });
            forumList.Add(new ForumInfo() { ForumID = 8, ParendID = 2, ForumName = "06S0D066", UbiRouteId = "0988" });
            forumList.Add(new ForumInfo() { ForumID = 9, ParendID = 2, ForumName = "06S0D067", UbiRouteId = "0988" }); 
            

          

            return forumList;
        }


  
    }
}
